package net.zoneland.geological.usermanage.controller;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import net.zoneland.geological.project.entity.Tbl_project;
import net.zoneland.geological.project.entity.Tbl_zht;
import net.zoneland.geological.project.service.Tbl_projectServiceI;
import net.zoneland.geological.project.service.Tbl_zhtServiceI;
import net.zoneland.geological.station.entity.Tbl_station_info;
import net.zoneland.geological.station.service.Tbl_station_infoServiceI;
import net.zoneland.geological.system.entity.Tbl_area;
import net.zoneland.geological.system.entity.ZTreeEntity;
import net.zoneland.geological.system.service.Tbl_areaServiceI;
import net.zoneland.geological.usermanage.entity.Tbl_role;
import net.zoneland.geological.usermanage.entity.Tbl_user;
import net.zoneland.geological.usermanage.entity.Tbl_user_datapermission;
import net.zoneland.geological.usermanage.service.Tbl_roleServiceI;
import net.zoneland.geological.usermanage.service.Tbl_userServiceI;
import net.zoneland.geological.usermanage.service.Tbl_user_datapermissionServiceI;
import net.zoneland.greenleaf.GLOBAL;
import net.zoneland.greenleaf.common.pagination.Pagination;
import net.zoneland.greenleaf.system.controller.BaseController;

/**
 * 用户数据权限配置表操作控制层(Controller|Action)

 * 表   名：TBL_USER_DATAPERMISSIONCONTROLLER<br/>
 * 注   释：用户数据权限配置表<br/>
 * 作   者：李义<br/>
 * 日   期：2017-08-09 18:46:00
**/
@Controller
@RequestMapping("tbl_user_datapermission")
public class Tbl_user_datapermissionController extends BaseController { 

	/**
	 * 如果需要系统对此Controller的访问进行监控，记录服务访问的时间，耗时，那么请将monitor属性设置为“true”
	 */

	public boolean monitor = false; 

	private static Logger logger = Logger.getLogger(Tbl_user_datapermissionController.class);

	//获取类的名称
	@SuppressWarnings("unused")
	private String clazzName = new Object() {
		public String getClassName() {
			String clazzName = this.getClass().getName();
			return clazzName.substring(0, clazzName.lastIndexOf('$'));
		}
	}.getClassName();

	/**
	 * tbl_user_datapermissionService
	 * @param tbl_user_datapermissionService
	**/
	@Autowired
	private Tbl_user_datapermissionServiceI tbl_user_datapermissionService;

	@Autowired
	private Tbl_areaServiceI tbl_areaService;
	
	@Autowired
	private Tbl_projectServiceI tbl_projectService;
	
	@Autowired
	private Tbl_station_infoServiceI tbl_station_infoService;

	@Autowired
	private Tbl_zhtServiceI tbl_zhtService;
	
	@Autowired
	private Tbl_userServiceI tbl_userService;
	
	@Autowired
	private Tbl_roleServiceI tbl_roleService;
	
	/**
	 * 根据ID获取信息数据
	 * @param id
	 * @return
	**/
	@RequestMapping( method = RequestMethod.GET, value = "/{id}", produces = "text/html;charset=UTF-8" )
	@ResponseBody
	public Object get( @PathVariable("id") String id ){
		Map<String, Object> map = new HashMap<String, Object>();
		Tbl_user_datapermission entity = null;
		Boolean check = true;

		map.put("id", id);
		if( id == null || "(0)".equals( id ) || id.isEmpty() ){
			check = false;
			map.put("result", "error");
			map.put("message", "系统获取到的ID不正常，ID:" + id );
		}
		if( check ){
			try {
				entity = tbl_user_datapermissionService.get( map );
			} catch (Exception e) {
				check = false;
				map.put("result", "error");
				map.put("message", "系统根据ID获取对象失败!");
				logger.error("系统根据ID获取对象发生异常。ID:" + id, e);
			}
		}
		if( check ){
			if( entity != null ){
				map.put( "result", "success");
				map.put( "data", entity );
			}else{
				map.put( "result", "error");
				map.put( "message", "数据不存在！ID:" + id );
			}
		}
		return map;
	}
	
	/**
	 * 根据ID获取信息数据
	 * @param id
	 * @return
	**/
	@RequestMapping( method = RequestMethod.GET, value = "/control/{area_code}", produces = "text/html;charset=UTF-8" )
	@ResponseBody
	public Object controlCity( @PathVariable("area_code") String area_code ){
		Map<String, Object> map = new HashMap<String, Object>();
		List<String> area_codes = null;
		Boolean check = true;
		Boolean isCityController = false;
		Tbl_user tbl_user = null;
		
		if( area_code == null || "(0)".equals( area_code ) || area_code.isEmpty() ){
			check = false;
			map.put("result", "error");
			map.put("message", "系统获取到的地区编码不正常，ID:" + area_code );
		}
		
		if( check ){
			if( this.getSession().getAttribute( "login_user" ) != null ) {
				tbl_user = (Tbl_user)this.getSession().getAttribute( "login_user" );
			}else {
				check = false;
				map.put( "result", "error" );
				map.put( "login", false );
				map.put( "message", "用户未登录!" );
			}
		}	
		
		if( check ){
			area_codes = tbl_areaService.getAreaCodesSupNested( area_code );
			if( !area_codes.contains( area_code )) {
				area_codes.add( area_code );
			}
		}
		if( check ){
			try {
				isCityController = tbl_user_datapermissionService.isCityController( tbl_user.getLogin_name(), area_codes );
			} catch (Exception e) {
				check = false;
				map.put("result", "error");
				map.put("message", "系统根据area_code获取数据权限!");
				logger.error("系统根据area_code获取数据权限。area_code:" + area_code, e);
			}
		}
		map.put( "result", "success");
		map.put( "data", isCityController );
		return map;
	}

	/**
	 * 获取用户数据权限配置表列表
	 * 返回JSON格式数据，如果不需要分页，您可以考虑将pagesize设置为足够大的数字，系统默认为20
	 * @param Map<String, Object> paramMap
	**/
	@RequestMapping( method = RequestMethod.POST, value = "/list" )
	@ResponseBody
	public Object list( @RequestBody Map<String, Object> paramMap ) {
		String page = "1";
		Integer pagesize = 20, totalRecord=0;
		List<Tbl_user_datapermission> list  = null;
		Map<String, Object> map=new HashMap<String,Object>();
		Pagination<?> pagination = null;
		Boolean check = true;

		if( paramMap == null ){
			check = false;
			map.put( "result", "error");
			map.put( "message", "参数列表为空，无法进行数据查询!");
		}
		if( check ){
			if( paramMap.get( "page" )!=null){
				page = paramMap.get( "page" ).toString();
			}
			if( paramMap.get( "pagesize") != null){
				try{
					pagesize = Integer.parseInt(paramMap.get( "pagesize" ).toString());
				}catch( Exception e ){
					pagesize = 20;
				}
			}
		}
		if( check ){
			try{
				totalRecord = tbl_user_datapermissionService.getListCount( paramMap );
			}catch( Exception e ){
				check = false;
				map.put( "result", "error");
				map.put( "message", "系统根据条件查询信息数据条目总数时发生异常!");
				logger.error( e );
			}
		}
		if( check ){
			try{
				pagination = Pagination.newPagination( pagesize, page, totalRecord );
				paramMap.put( "startRow", pagination.getStartRow() );
				paramMap.put( "pageSize", pagesize );
				/**
			 	* 如果需要按某列进行排序，可以再多给两个参数：orderColName, orderType
			 	* paramMap.put( "orderColName", "ID");
			 	* paramMap.put( "orderType", "DESC");
			 	**/
			}catch( Exception e ){
				check = false;
				map.put( "result", "error" );
				map.put( "message", "系统根据条件进行分页信息计算时发生异常！" );
				logger.error( e );
			}
		}
		if( check ){	
			if( totalRecord>0 ){
				try{
					list = tbl_user_datapermissionService.getList( paramMap );
				}catch( Exception e ){
					check = false;
					map.put( "result", "error" );
					map.put( "message", "系统根据条件进行信息列表查询信息数据时发生异常!" );
					logger.error( e );
				}
			}
		}
		if( check ){
			if( list == null ){
				list = new ArrayList<Tbl_user_datapermission>();
			}
		}
		if( check ){
			map.put( "result", "success" );
			map.put( "message", "系统查询信息数据成功!" );
			map.put( "pagination", pagination );
			map.put( "data", list );
		}
		return map;
	}
	
	@RequestMapping( method = RequestMethod.GET, value = "/listAllTree" )
	@ResponseBody
	public Object listAllTree() {
		Map<String, Object> map =new HashMap<String,Object>();
		Map<String, Object> paramMap =new HashMap<String,Object>();
		Boolean check = true;
		Tbl_area area = null;
		List<Tbl_area> counties = null;
		ZTreeEntity treeRoot = null;
		ZTreeEntity city_entity = null;
		ZTreeEntity entity = null;
		
		//先查询所有省份:广东省
		if( check ){
			try{
				paramMap.put( "area_code" , GLOBAL.SYSTEM_PROVINDE_CODE );
				area = tbl_areaService.getWithCode( paramMap );
			}catch( Exception e ){
				check = false;
				map.put( "result", "error");
				map.put( "message", "系统查询地区信息时发生异常!area_code:" + GLOBAL.SYSTEM_PROVINDE_CODE );
				logger.error( e );
			}
		}
		//查询深圳市，并且放入树结果里作为child
		if( check ){
			if( area != null ) {
				treeRoot = new ZTreeEntity( area.getArea_code(), area.getArea_name(), "PROVINCE#"+area.getArea_code(),  "0", 1, "myTree-level1", true, null );
				try{
					paramMap.put( "area_code" , GLOBAL.SYSTEM_CITY_CODE );
					area = tbl_areaService.getWithCode( paramMap );
				}catch( Exception e ){
					check = false;
					map.put( "result", "error");
					map.put( "message", "系统查询地区信息时发生异常!area_code:" + GLOBAL.SYSTEM_CITY_CODE );
					logger.error( e );
				}
			}else {
				check = false;
				map.put( "result", "error");
				map.put( "message", "地区信息不存在!area_code:" + GLOBAL.SYSTEM_PROVINDE_CODE );
			}
		}
		if( check ){
			if( area != null ) {
				city_entity = new ZTreeEntity( area.getArea_code(), area.getArea_name(), "CITY#"+area.getArea_code(),  treeRoot.getId(), 2, "myTree-level1", true, null );
				treeRoot.addChild( city_entity );
			}else {
				check = false;
				map.put( "result", "error");
				map.put( "message", "地区信息不存在!area_code:" + GLOBAL.SYSTEM_CITY_CODE );
			}
		}
		//再查询深圳市所有的县信息，列表
		if( check ){
			paramMap.clear();
			paramMap.put( "parent_code", GLOBAL.SYSTEM_CITY_CODE );
			try{
				counties = tbl_areaService.getList( paramMap );
			}catch( Exception e ){
				check = false;
				map.put( "result", "error");
				map.put( "message", "系统根据上级编码查询地区信息时发生异常!parent_code:"+ GLOBAL.SYSTEM_CITY_CODE );
				logger.error( e );
			}
		}
		if( check ){
			if( counties != null ) {
				for( Tbl_area county : counties ) {
					try {
						entity = new ZTreeEntity( county.getArea_code(), county.getArea_name(), "COUNTY#"+county.getArea_code(),  city_entity.getId(), 3, "myTree-level1", true, null );
						entity = composeCounty( entity );
						city_entity.addChild( entity );
					}catch( Exception e ) {
						e.printStackTrace();
					}
				}
			}else {
				try {
					city_entity = composeCity( city_entity );
				}catch( Exception e ) {
					e.printStackTrace();
				}
			}
		}
		if( check ){
			map.put( "result", "success" );
			map.put( "message", "系统查询信息数据成功!" );
			map.put( "data", treeRoot );
		}
		return map;
	}

	private ZTreeEntity composeCity(ZTreeEntity entity) throws Exception {
		//1、查询项目信息
		ZTreeEntity temp = null;
		List<Tbl_project> project_list = null;
		Map<String, Object> paramMap =new HashMap<String,Object>();
		if( entity != null ) {
			paramMap.put( "city_code", entity.getId() );
			project_list = tbl_projectService.getList( paramMap );
			if( project_list != null ) {
				for( Tbl_project project : project_list ) {
					try {
						temp = new ZTreeEntity( project.getId(), project.getDescription(), "PROJECT#"+project.getId(), entity.getId(), 4, "myTree-level1", true, null );
						temp = composeProject( temp );
						entity.addChild( temp );
					}catch( Exception e ) {
						e.printStackTrace();
					}
				}
			}
		}
		return entity;
	}

	/**
	 * 根据地区信息组织树状信息
	 * 1、项目信息
	 * 2、灾害体信息
	 * 3、站点信息
	 * @param entity
	 * @return
	 * @throws Exception 
	 */
	private ZTreeEntity composeCounty( ZTreeEntity entity ) throws Exception {
		//1、查询项目信息
		ZTreeEntity temp = null;
		List<Tbl_project> project_list = null;
		Map<String, Object> paramMap =new HashMap<String,Object>();
		if( entity != null ) {
			paramMap.put( "area_code", entity.getId() );
			project_list = tbl_projectService.getList( paramMap );
			if( project_list != null ) {
				for( Tbl_project project : project_list ) {
					try {
						temp = new ZTreeEntity( project.getId(), project.getDescription(), "PROJECT#"+project.getId(),  entity.getId(), 4, "myTree-level1", true, null );
						temp = composeProject( temp );
						entity.addChild( temp );
					}catch( Exception e ) {
						e.printStackTrace();
					}
				}
			}
		}
		return entity;
	}

	/**
	 * 根据項目信息组织树状信息
	 * 1、灾害体信息
	 * 2、站点信息
	 * @param entity
	 * @return
	 * @throws Exception 
	 */
	private ZTreeEntity composeProject( ZTreeEntity entity ) throws Exception {
		//1、查询项目信息
		ZTreeEntity temp = null;
		List<Tbl_zht> zht_list = null;
		Map<String, Object> paramMap =new HashMap<String,Object>();
		if( entity != null ) {
			paramMap.put( "project_id", entity.getId() );
			zht_list = tbl_zhtService.getList( paramMap );
			if( zht_list != null ) {
				for( Tbl_zht zht : zht_list ) {
					try {
						temp = new ZTreeEntity( zht.getId(), zht.getName(), "ZHT#"+zht.getId(),  entity.getId(), 5, "myTree-level1", false, null );
						//temp = composeZht( temp );
						entity.addChild( temp );
					}catch( Exception e ) {
						e.printStackTrace();
					}
				}
			}
		}
		return entity;
	}
	/**
	 * 根据災害體信息组织树状信息(暂时不用，只到灾害体)
	 * 2、站点信息
	 * @param entity
	 * @return
	 * @throws Exception 
	 */
	private ZTreeEntity composeZht(ZTreeEntity entity) throws Exception {
		//1、查询项目信息
		ZTreeEntity temp = null;
		List<Tbl_station_info> station_info_list = null;
		Map<String, Object> paramMap =new HashMap<String,Object>();
		if( entity != null ) {
			paramMap.put( "zht_id", entity.getId() );
			station_info_list = tbl_station_infoService.getList( paramMap );
			if( station_info_list != null ) {
				for( Tbl_station_info station_info : station_info_list ) {
					temp = new ZTreeEntity( station_info.getStation_id(), station_info.getStation_name(), "STATION#"+station_info.getStation_id(),  entity.getId(), 6, "myTree-level1", false, null );
					temp = composeZht( temp );
					entity.addChild( temp );
				}
			}
		}
		return entity;
	}

	/**
	 * 增加或编辑一个用户数据权限配置表信息
	 * 返回JSON格式数据
	 * @param entity
	**/
	@RequestMapping( method = RequestMethod.POST, value = "/save" )
	@ResponseBody
	public Object save( @RequestBody Map<String, Object> paramMap ){
		Map<String, Object> map = new HashMap<String, Object>();
		Map<String, Object> queryMap = new HashMap<String, Object>();
		Tbl_user_datapermission entity = null;
		String object_code = null;
		String object_type = null;
		String object_name = null;
		String data_permission = null;
		String perm_code = null;
		String perm_type = null;
		Tbl_user user = null;
		Tbl_role role = null;
		Boolean check = true;

		if( paramMap == null ){
			check = false;
			map.put( "result", "error");
			map.put( "message", "需要保存的信息数据为空!");
		}
		
		if( check ){
			if( paramMap.get( "object_type" ) == null ) {
				check = false;
				map.put( "result", "error");
				map.put( "message", "权限绑定对象类别[object_type]不能爲空!");
			}else {
				object_type = (String)paramMap.get( "object_type" );
			}
		}
		
		if( check ){
			if( paramMap.get( "object_code" ) == null ) {
				check = false;
				map.put( "result", "error");
				map.put( "message", "权限绑定对象编码[object_code]不能爲空!");
			}else {
				object_code = (String)paramMap.get( "object_code" );
			}
		}
		
		if( check ){
			if( paramMap.get( "permission" ) == null ) {
				check = false;
				map.put( "result", "error");
				map.put( "message", "權限信息不能爲空!");
			}else {
				data_permission = (String)paramMap.get( "permission" );
			}
		}
		
		if( check ){
			if( data_permission.split( "#" ).length > 1 ) {
				perm_type = data_permission.split( "#" )[0];
				perm_code = data_permission.split( "#" )[1];
			}
		}
		
		if( check ){//根據ID查詢用戶信息是否有效
			if( "USER".equalsIgnoreCase( object_type )) {
				queryMap.put( "login_name", object_code );
				try {
					user = tbl_userService.get( queryMap );
					if( user == null ) {
						check = false;
						map.put( "result", "error");
						map.put( "message", "用戶信息不存在!");
					}else {
						object_name = user.getName();
					}
				} catch (Exception e) {
					check = false;
					map.put( "result", "error");
					map.put( "message", "根據ID查詢用戶信息时发生异常!");
					logger.error( "根據ID查詢用戶信息时发生异常!", e );
				}
			}else if("ROLE".equalsIgnoreCase( object_type )) {
				queryMap.put( "code", object_code );
				try {
					role = tbl_roleService.get( queryMap );
					if( role == null ) {
						check = false;
						map.put( "result", "error");
						map.put( "message", "角色信息不存在!");
					}else {
						object_name = role.getName();
					}
				} catch (Exception e) {
					check = false;
					map.put( "result", "error");
					map.put( "message", "根據CODE查詢角色信息时发生异常!");
					logger.error( "根據CODE查詢角色信息时发生异常!", e );
				}
			}
		}
		
		if( check ){
			entity = new Tbl_user_datapermission();
			//entity.setId(_id);
			entity.setObject_code(object_code);
			entity.setObject_name(object_name);
			entity.setObject_type(object_type);
			entity.setPerm_code( perm_code );
			entity.setPerm_level( perm_type );
			entity.setCreate_time( new Date() );
			entity.setUpdate_time( entity.getCreate_time() );
			entity.setDeleted( 0 );
			entity.setVersion( 1 );
			//entity.setDescription(_description);
		}
		
		if( check ){
			if( "PROVINCE".equals( perm_type ) || "CITY".equals( perm_type ) || "COUNTY".equals( perm_type ) ) {
				queryMap.clear();
				queryMap.put( "area_code", perm_code );
				Tbl_area area = null;
				try {
					area = tbl_areaService.get( queryMap );
					if( area == null ) {
						check = false;
						map.put( "result", "error");
						map.put( "message", "地區信息不存在!" + perm_code );
					}else {
						entity.setDescription( area.getArea_full_name() );
					}
				} catch (Exception e) {
					check = false;
					map.put( "result", "error");
					map.put( "message", "根據ID查詢地區信息时发生异常!" + perm_code );
					logger.error( "根據ID查詢地區信息时发生异常!" + perm_code, e );
				}
			}else if( "PROJECT".equals( perm_type )) {
				queryMap.clear();
				queryMap.put( "id", perm_code );
				Tbl_project project = null;
				try {
					project = tbl_projectService.get( queryMap );
					if( project == null ) {
						check = false;
						map.put( "result", "error");
						map.put( "message", "項目信息不存在!" + perm_code );
					}else {
						entity.setDescription( project.getDescription() );
					}
				} catch (Exception e) {
					check = false;
					map.put( "result", "error");
					map.put( "message", "根據ID查詢項目信息时发生异常!" + perm_code );
					logger.error( "根據ID查詢項目信息时发生异常!" + perm_code, e );
				}
			}else if( "ZHT".equals( perm_type )) {
				queryMap.clear();
				queryMap.put( "id", perm_code );
				Tbl_zht zht = null;
				try {
					zht = tbl_zhtService.get( queryMap );
					if( zht == null ) {
						check = false;
						map.put( "result", "error");
						map.put( "message", "災害體信息不存在!" + perm_code );
					}else {
						entity.setDescription( zht.getName() );
					}
				} catch (Exception e) {
					check = false;
					map.put( "result", "error");
					map.put( "message", "根據ID查詢災害體信息时发生异常!" + perm_code );
					logger.error( "根據ID查詢災害體信息时发生异常!" + perm_code, e );
				}
			}else if( "STATION".equals( perm_type )) {
				queryMap.clear();
				queryMap.put( "station_id", perm_code );
				Tbl_station_info station_info = null;
				try {
					station_info = tbl_station_infoService.get( queryMap );
					if( station_info == null ) {
						check = false;
						map.put( "result", "error");
						map.put( "message", "站點信息不存在!" + perm_code );
					}else {
						entity.setDescription( station_info.getStation_name() );
					}
				} catch (Exception e) {
					check = false;
					map.put( "result", "error");
					map.put( "message", "根據ID查詢站點信息时发生异常!" + perm_code );
					logger.error( "根據ID查詢站點信息时发生异常!" + perm_code, e );
				}
			}
		}

		if( check ){
			try{
				entity = tbl_user_datapermissionService.addOrUpdate( entity );
				map.put( "result", "success");
				map.put( "message", "保存用户数据权限配置表信息数据成功!");
				map.put( "data", entity );
			}catch( Exception e ){
				map.put( "result", "error" );
				map.put( "message", "保存用户数据权限配置表信息数据失败!" );
				logger.error("保存用户数据权限配置表信息数据失败!", e);
			}
		}
		return map;
	}

	/**
	 * 对需要进行保存的对象里的信息校验
	 * @param entity
	 * @param map 
	 * @return
	 */
	private Map<String, Object> validate( Tbl_user_datapermission entity, Map<String, Object> map ) {
		//TODO 这里进行所有的数据校验工作
		map.put("result", "success");
		return map;
	}

	/**
	 * 根据ID删除一个用户数据权限配置表信息
	 * 返回JSON格式数据
	 * @param int id
	**/
	@RequestMapping( method = RequestMethod.DELETE, value = "/{id}" )
	@ResponseBody
	public Object deleteById( @PathVariable( "id" ) String id ){
		Map<String, Object> map = new HashMap<String, Object>();
		Tbl_user_datapermission entity = null;
		Boolean check = true;

		map.put( "id", id );
		if( id == null || id.isEmpty() || "id".equalsIgnoreCase( id )){
			check = false;
			map.put( "result", "error" );
			map.put( "message", "需要删除的信息ID为空!" );
		}
		if( check ){
			try {
				entity = tbl_user_datapermissionService.get( map );
				if( entity == null ){
					check = false;
					map.put( "result", "error" );
					map.put( "message", "需要删除的信息数据不存在失败!ID:" + id );
				}
			} catch (Exception e) {
				check = false;
				map.put( "result", "error" );
				map.put( "message", "根据ID查询需要删除的信息数据失败!ID:" + id );
				logger.error( "根据ID查询需要删除的信息数据失败!ID:" + id, e);
			}
		}
		if( check ){
			try {
				tbl_user_datapermissionService.delete( map );
				map.put( "result", "success" );
				map.put( "message", "成功删除一个信息数据!" );
			} catch (Exception e) {
				check = false;				map.put( "result", "error");
				map.put( "message", "删除信息数据失败!ID:" + id );
				logger.error( "删除信息数据失败!ID:" + id, e);
			}
		}
		return map;
	}

	/**
	 * 根据ID删除多个用户数据权限配置表信息
	 * 返回JSON格式数据
	 * @param Map<String, Object> paramMap
	**/
	@RequestMapping( method = RequestMethod.POST, value = "/delete/batch" )
	@ResponseBody
	public Object deleteByIds( @RequestBody Map<String, Object> paramMap ){
		Map<String, Object> map = new HashMap<String, Object>();
		String ids_str = null;
		Boolean check = true;

		if( paramMap == null || paramMap.get( "ids" ) == null ){
			check = false;
			map.put( "result", "error" );
			map.put( "message", "参数列表为空，无法进行数据删除!" );
		}
		if( check ){
			ids_str = (String)paramMap.get( "ids" );
			if( ids_str != null && ids_str.isEmpty() ){
				check = false;
				map.put( "result", "error" );
				map.put( "message", "参数列表中ID列表为空，无法进行数据删除!" );
			}else{
				map.put( "ids", ids_str.split( "," ) );
			}
		}
		if( check ){
			try {
				tbl_user_datapermissionService.delete( map );
				map.put( "result", "success" );
				map.put( "message", "成功删除信息数据!" );
			} catch (Exception e) {
				map.put( "result", "error" );
				map.put( "message", "删除信息数据失败!ID:" + paramMap.get( "ids" ) );
				logger.error( "系统信息数据失败!ID:" + paramMap.get( "ids" ), e );
			}
		}
		return map;
	}
}
